package com.hospital.controller;

import com.hospital.dao.CaserecordDao;
import com.hospital.domain.Caserecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
@RequestMapping("/case")
public class CaserecordController {

    @Autowired
    CaserecordDao dao;
     @GetMapping("/selectByuserID")
    public List<Caserecord> selectCaserecodeByUserID(HttpSession session){
         int i = (int)session.getAttribute("userID");
         System.out.println(i);
         return dao.selectCaserecordByUserID(i);
     }


     @PostMapping("/addCase")
     public int addCaserecord(@RequestBody Caserecord caserecord){
         return dao.addCaserecord(caserecord);
     }


     @GetMapping("/isGrade")
     public int isGrade(int caseID){
         return dao.isGrade(caseID);
     }

     @GetMapping("/addRate")
     public int addRate(@RequestParam("caseID") int caseID,@RequestParam("rate") int rate){
         return dao.addRate(caseID,rate);
     }
}
